#include <ctime>
#include <cstdlib>
#include <iostream>
#include <unistd.h>

// #include "singleThreadPool.hpp"
#include "SingleThreadPool.hpp"
#include "Task.hpp"

int main()
{
    srand((unsigned long)time(nullptr) ^ getpid());

    // ThreadPool<Task> *tp = new ThreadPool<Task>();
    // ThreadPool<Task> *tp = ThreadPool<Task>::getThreadPoolInstance();

    //tp->run();
    singleThreadPool<Task>::getThreadPoolInstance()->run();

    while (true)
    {
        // 生产数据/制作任务 -- 耗费时间
        int x = rand() % 10 + 1;
        usleep(1000);
        int y = rand() % 5 + 1;
        Task t(x, y, [](int x, int y) -> int
               { return x + y; });

        logMsg(DEBUG, "Main-Pro 发送任务: %d+%d=未知", x, y);

        // 推送任务到线程池中
        // tp->pushTask(t);
        singleThreadPool<Task>::getThreadPoolInstance()->pushTask(t);
        sleep(1);
    }
    return 0;
}
